package com.example.leetcode;

import java.util.*;

public class HW02 {
    private static void test2(){
        String s ="aaacclllrrrrrccc";
        char[] chars = s.toCharArray();
        int maxlen = 0;

        for (int i = 0; i < chars.length; i++) {
            int index = i;
            int len = 1;
            while (index + 1 < chars.length && chars[index + 1] == chars[index]) {
                len++;
                index++;
            }
            if (len > maxlen) maxlen = len;
        }

        System.out.println(maxlen);

    }
    public static void main(String[] args) {
        String s="aaacclllrrrrrccc";
        test2();
        char[] characters =s.toCharArray();
        List<Integer> integers = new ArrayList<>();
      for (int i=0;i<characters.length;i++){
          int count = 1;
          for (int j=i+1;j<characters.length;j++){
              if (characters[i]!=characters[j]){
                  break;
              }
              count++;
          }
          integers.add(count);
      }
        System.out.println(Collections.max(integers));
    }
}
